package com.ansion.utils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.ObjectsCompat;

/**
 * Description:
 * <p>
 * Created by ____lamer on 2019-10-29 15:32
 */
public class Pair<F, S> {
    @Nullable
    public F first;
    @Nullable
    public S second;

    public boolean equals(Object o) {
        if (!(o instanceof androidx.core.util.Pair)) {
            return false;
        } else {
            androidx.core.util.Pair<?, ?> p = (androidx.core.util.Pair) o;
            return ObjectsCompat.equals(p.first, this.first) && ObjectsCompat.equals(p.second, this.second);
        }
    }

    public int hashCode() {
        return (this.first == null ? 0 : this.first.hashCode()) ^ (this.second == null ? 0 : this.second.hashCode());
    }

    public String toString() {
        return "Pair{" + this.first + " " + this.second + "}";
    }

    @NonNull
    public static <A, B> Pair<A, B> create(@Nullable A a, @Nullable B b) {
        Pair<A, B> pair = new Pair<>();
        pair.first = a;
        pair.second = b;
        return pair;
    }
}
